
$mailsrv	    = "mailsrv"
$fromaddr           = "user@domain"
$sitename           = "Home"

$srvlist            = "c:\scripts\hosts.txt"
$scriptpath         = "c:\scripts\diskspace.ps1"
$runuser            = "sched"
$runpass            = 'Pa$$w0rd'

$mailuser           = 'mailer'
$mailpass           = 'Pa$$w0rd'

$recipients_onetm   = 'c:\scripts\recipients.txt'
$recipients_daily	= 'c:\scripts\recipients_daily.txt'
$recipients_hourly	= 'c:\scripts\recipients_hourly.txt'

if ($args.count -eq 0) {
    $recipients = $recipients_onetm
    $script		= "powershell.exe $scriptpath $sitename $srvlist $mailsrv $fromaddr $recipients $mailuser $mailpass"
    
    Invoke-Expression $script
}
elseif ($args[0] -eq '-hourly') {
    $recipients = $recipients_hourly
    $script		= "powershell.exe $scriptpath $sitename $srvlist $mailsrv $fromaddr $recipients $mailuser $mailpass"
    
    schtasks /Create /F /SC HOURLY /ST 15:15 /RU $runuser /RP $runpass /TN StorageReportHourly  /TR "$script"
}
elseif ($args[0] -eq '-daily') {
    $recipients = $recipients_daily
    $script		= "powershell.exe $scriptpath $sitename $srvlist $mailsrv $fromaddr $recipients $mailuser $mailpass"
    
    schtasks /Create /F /SC DAILY  /ST 07:00 /RU $runuser /RP $runpass /TN StorageReportDaily   /TR "$script"
}
